<template>
	<view>
		<view class="my-custom" :style="[{height:CustomBar + 'px'}]">
			<view class="my-bar fixed" :style="style" :class="[bgImage!=''?'none-bg text-white bg-img':'',bgColor]">
				<view class="left" @tap="BackPage" v-if="left">
					<slot name="left"></slot>
				</view>
				<view class="content" v-if="content">
					<slot name="content"></slot>
				</view>
				<view class="right" v-if="right">
					<slot name="right"></slot>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar
			};
		},
		name: 'cu-custom',
		computed: {
			style() {
				var StatusBar= this.StatusBar;
				var CustomBar= this.CustomBar;
				var bgImage = this.bgImage;
				var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
				if (this.bgImage) {
					style = `${style}background-image:url(${bgImage});`;
				}
				return style
			}
		},
		props: {
			bgColor: {
				type: String,
				default: ''
			},
			left: {
				type: [Boolean, String],
				default: false
			},
			content: {
				type: [Boolean, String],
				default: false
			},
			right: {
				type: [Boolean, String],
				default: false
			},
			bgImage: {
				type: String,
				default: ''
			},
		},
		methods: {
			BackPage() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	}
</script>

<style>
.my-custom .my-bar{
	display: flex;
	align-items: center;
}
.my-bar .left{
	padding-left: 25rpx;
	flex: 1;
}
.my-bar .content{
	flex: 3;
}
.my-bar .right{
	flex: 1;
	text-align: right;
	padding-right: 25rpx;
}
</style>
